package com.zm.damai.damaiuser.web;

import com.zm.damaicommon.Result;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
public class UserDo {
    @RequestMapping("user")
    String user(HttpServletRequest request){
        return "user:" + request.getServerPort();
    }

    @RequestMapping("hello")
    String hello(@RequestParam("name") String name){
        return "hello:" + name;
    }

    @RequestMapping("add")
    int add(@RequestParam("x") int x,@RequestParam("y") int y){
        return x + y;
    }

    @RequestMapping("sub/{x}/{y}")
    int sub(@PathVariable int x,@PathVariable int y){
        return x - y;
    }

    @RequestMapping("result")
    Result result(@RequestBody Result result){
        result.setCode(result.getCode() + 100);
        return result;
    }



}
